﻿using System;
using System.Linq;
using System.Reflection;
using Abp.EntityFrameworkCore;
using AbpDemo.Domain.Goods;
using AbpDemo.Domain.Orders;
using Microsoft.EntityFrameworkCore;

namespace AbpDemo.EntityFrameworkCore
{
    public class AbpDemoDbContext : AbpDbContext
    {
        //Add DbSet properties for your entities...

        public AbpDemoDbContext(DbContextOptions<AbpDemoDbContext> options) 
            : base(options)
        {

        }

        #region DbSet
        //TODO: IRepository 依赖的错误 --DbSet

        public DbSet<Order_1> Orders { get; set; }
        public DbSet<OrderItem_1> OrderItems { get; set; }
        public DbSet<Goods_1> Goods { get; set; }


        #endregion


        #region Configured by Fluent API
// TODO: Fluent API
       /* protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            var assembly = Assembly.GetExecutingAssembly();
            var types = assembly.GetTypes()
                .Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null);

            if (types != null)
            {
                foreach (var type in types)
                {
                    dynamic configurationInstance = Activator.CreateInstance(type);
                    modelBuilder.ApplyConfiguration(configurationInstance);
                }
            }
        }*/

        #endregion
    }
}
